<template>
  <div>
    <div class="activity-box">
      <h2>创建活动</h2>
      <form @submit='formSubmit'>
        <ul>
          <li>
            <span>活动标题:</span>
            <input type="text" name="title">
          </li>
          <li>
            <span>开始时间:</span>
            <div class="dateSelect" >
              <DateSelect ></DateSelect>
            </div>
          </li>
          <li>
            <span>结束时间:</span>
            <div class="dateSelect" >
              <DateSelectc ></DateSelectc>
            </div>
          </li>
          <li>
            <span>活动地点:</span>
            <input type="text" name="local">
          </li>
          <li>
            <span>报名人数:</span>
            <input type="text" name="number">
          </li>
          <li>
            <span>负责人:</span>
            <input type="text" name="name">
          </li>
          <li>
            <span>联系方式:</span>
            <input type="text" name="phone">
          </li>
          <li>
            <span>报名要求:</span>
            <input type="text" name="need">
          </li>
          <li>
            <span>活动说明:</span>
            <input type="text" name="detail">
          </li>
        </ul>
        <button form-type='submit'>提交</button>
      </form>
    </div>
  </div>
</template>


<script>
import DateSelect from '@/components/dateSelect'
import DateSelectc from '@/components/dateSelectC'
import request from '../../utils/request'
  export default{
    components:{
      DateSelect,
      DateSelectc

    },
    data(){
      return {
        startTime:'',
        endTime:'',
      }
    },
    
    methods: {
      async formSubmit(e){ 
        let data = {
          data1: e.mp.detail.value,
          sno: wx.getStorageSync('user').sno
        }
        console.log(data);
        let result = await request('/activity/create',{data},'GET');
        console.log(result)
        if(result.status===0){
          wx.showToast({
            title: '创建失败',
            duration: 5000
          })
          wx.navigateBack({
            delta: 1
          })
        }else{
          wx.showToast({
            title: '创建失败',
            duration: 5000
          })
        }

      }
    },
   
  }
</script>

<style scoped>
.activity-box{
  width:100%;
  height:auto;
}
.activity-box h2{
  text-align: center;
  color: red;

}
.activity-box form{
  width:100%;
  height: auto;
}

.activity-box form li{
  height: 50px;
  padding-top: 20px;
  margin:0 20px;
}
.activity-box form li span{
  margin-left: 10px;
  margin-top:20px;
  color:red;
}
.activity-box form li input{
  border-bottom: 1px saddlebrown solid;
  width:70%;
  float: right;
  
}


.activity-box form li .dateSelect{
  border-bottom: 1px saddlebrown solid;
  width:70%;
  float: right;
  
}
button{
  background-color: red
}
</style>
 